/**
 * Created by hjx on 2018/2/8.
 */
(function () {
    var exports = this;

    var $ = null;

    var javaClubCommonInputLayer = cc.Layer.extendEX({
        ctor: function (strContent, call, typ) {
            this._super();
            var that = this;
            loadNodeCCS(res.ClubCommonInputPanl_json, this);
            $ = create$(this.getChildByName('Layer'));
            this.call = call;
            // $('lb_content').setString(strContent);
            $('lb_content').setVisible(false);


            var changebgtxt = new cc.EditBox(cc.size(230, 30), new cc.Scale9Sprite(javaClub.res.transparent_64x64));
            $('input').getParent().addChild(changebgtxt);
            changebgtxt.setName('searchTxt');
            changebgtxt.setPosition($('input').getPosition());
            changebgtxt.setFontColor(cc.color('#CB5F19'));
            changebgtxt.setPlaceholderFontColor(cc.color(175, 133, 108));
            changebgtxt.setDelegate(this);
            changebgtxt.setMaxLength(6);
            changebgtxt.setFontSize(26);
            changebgtxt.setPlaceholderFontSize(26);
            this.changebgtxt = changebgtxt;
            changebgtxt.setPlaceHolder(strContent);

            this._strContent = strContent;

            this._changebgtxt = changebgtxt;
            $('titleId').setVisible(false);
            // 修改备注特殊处理
            if(typ){
                $('title').setVisible(false);
                $('beizhu').setVisible(true);
            }
            if(strContent.indexOf('请输入玩家Id') >= 0){
                $('title').setVisible(false);
                $('beizhu').setVisible(false);
                $('titleId').setVisible(true);
            }

            TouchUtil.setOnclickListener($('btn_cancel'), function () {
                that.removeFromParent();
            });

            TouchUtil.setOnclickListener($('btn_ok'), function () {
                var input = that._changebgtxt.getString();
                that.call(input);
                that.removeFromParent();
            });
            return true;
        },

        editBoxEditingDidBegin: function (editBox) {
            this._changebgtxt.setPlaceHolder('')
        },
        editBoxEditingDidEnd: function (editBox) {
            var input = this._changebgtxt.getString();
            if(input.length == 0){
                this._changebgtxt.setPlaceHolder(this._strContent);
            }
        },
        editBoxTextChanged: function (editBox, text) {
        },
        editBoxReturn: function (editBox) {
        },
    });

    exports.javaClubCommonInputLayer = javaClubCommonInputLayer;
})(window);